$(function(){

    var hei = $(document).height();
    $("#rightFrame").css("height", hei);

    layui.use('element', function(){
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        //监听导航点击
        element.on('nav(left-menu)', function(elem){
            console.info(elem);
            $('.layui-nav-tree .layui-nav-item .menu-img .not-highlight-img').addClass('hide-img');
            $('.layui-nav-tree .layui-nav-item .menu-img .highlight-img').removeClass('hide-img');
            $('.layui-nav-tree .layui-this .menu-img .not-highlight-img').removeClass('hide-img');
            $('.layui-nav-tree .layui-this .menu-img .highlight-img').addClass('hide-img');
        });
    });

    if(!loginCheck()){
        return;
    }

    //初始化右侧内容页面
    locationContentFrame('activitymanage.html');
});

function loginCheck(){
    var encrystring = GetQueryString("encrystring");
    var loginStatus = false;
    if(encrystring != null && encrystring != ""){
        $.ajax({
            url: "./specialLogin.do",
            type: "get",
            cache: false,
            data: {"encrystring": encrystring},
            dataType: "json",
            async: false,
            success: function (data) {
                if(data && data.result == "success"){
                    console.log("特殊登录登录成功");
                    loginStatus = true;
                }
                else{
                    alert("登录失败，请检查登录信息");
                }
            },
            error: function (data) {
                alert("登录失败，请检查登录信息");
            }
        })
    }
    else{
        loginStatus = true;
    }
    return loginStatus;
}

function locationContentFrame(htmlPath) {
    // window.parent.frames[2].location.href = htmlPath;
    $('#rightFrame').prop("src", "./" + htmlPath);
}
